﻿namespace HRM.CORE
{

    using APP.HELPER.Data.Helper;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;

    public class HRM_REWARD
    {
        private DateTime m_Date;
        private DateTime m_DecideDate;
        private string m_DecideNumber;
        private string m_Form;
        private string m_Foundation;
        private string m_Level;
        private string m_Object;
        private string m_Person;
        private string m_Reason;
        private string m_RewardCode;
        private string m_Source;
        private int m_Status;
        private decimal m_TotalValue;

        public HRM_REWARD()
        {
            this.m_RewardCode = "";
            this.m_Foundation = "";
            this.m_Reason = "";
            this.m_Object = "";
            this.m_Form = "";
            this.m_Level = "";
            this.m_Source = "";
            this.m_TotalValue = 0M;
            this.m_Status = 0;
            this.m_Date = DateTime.Now;
            this.m_DecideNumber = "";
            this.m_DecideDate = DateTime.Now;
            this.m_Person = "";
        }

        public HRM_REWARD(string RewardCode, string Foundation, string Reason, string Object, string Form, string Level, string Source, decimal TotalValue, int Status, DateTime Date, string DecideNumber, DateTime DecideDate, string Person)
        {
            this.m_RewardCode = RewardCode;
            this.m_Foundation = Foundation;
            this.m_Reason = Reason;
            this.m_Object = Object;
            this.m_Form = Form;
            this.m_Level = Level;
            this.m_Source = Source;
            this.m_TotalValue = TotalValue;
            this.m_Status = Status;
            this.m_Date = Date;
            this.m_DecideNumber = DecideNumber;
            this.m_DecideDate = DecideDate;
            this.m_Person = Person;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@RewardCode" };
            object[] myValues = new object[] { this.m_RewardCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_REWARD_Delete", myParams, myValues);
        }

        public string Delete(string RewardCode)
        {
            string[] myParams = new string[] { "@RewardCode" };
            object[] myValues = new object[] { RewardCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_REWARD_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, string RewardCode)
        {
            string[] myParams = new string[] { "@RewardCode" };
            object[] myValues = new object[] { RewardCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_REWARD_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, string RewardCode)
        {
            string[] myParams = new string[] { "@RewardCode" };
            object[] myValues = new object[] { RewardCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_REWARD_Delete", myParams, myValues);
        }

        public bool Exist(string RewardCode)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@RewardCode" };
            object[] myValues = new object[] { RewardCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_REWARD_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(string RewardCode)
        {
            string str = "";
            string[] myParams = new string[] { "@RewardCode" };
            object[] myValues = new object[] { RewardCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_REWARD_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RewardCode = Convert.ToString(reader["RewardCode"]);
                    this.m_Foundation = Convert.ToString(reader["Foundation"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Object = Convert.ToString(reader["Object"]);
                    this.m_Form = Convert.ToString(reader["Form"]);
                    this.m_Level = Convert.ToString(reader["Level"]);
                    this.m_Source = Convert.ToString(reader["Source"]);
                    this.m_TotalValue = Convert.ToDecimal(reader["TotalValue"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_DecideDate = Convert.ToDateTime(reader["DecideDate"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, string RewardCode)
        {
            string str = "";
            string[] myParams = new string[] { "@RewardCode" };
            object[] myValues = new object[] { RewardCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_REWARD_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RewardCode = Convert.ToString(reader["RewardCode"]);
                    this.m_Foundation = Convert.ToString(reader["Foundation"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Object = Convert.ToString(reader["Object"]);
                    this.m_Form = Convert.ToString(reader["Form"]);
                    this.m_Level = Convert.ToString(reader["Level"]);
                    this.m_Source = Convert.ToString(reader["Source"]);
                    this.m_TotalValue = Convert.ToDecimal(reader["TotalValue"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_DecideDate = Convert.ToDateTime(reader["DecideDate"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, string RewardCode)
        {
            string str = "";
            string[] myParams = new string[] { "@RewardCode" };
            object[] myValues = new object[] { RewardCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_REWARD_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RewardCode = Convert.ToString(reader["RewardCode"]);
                    this.m_Foundation = Convert.ToString(reader["Foundation"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Object = Convert.ToString(reader["Object"]);
                    this.m_Form = Convert.ToString(reader["Form"]);
                    this.m_Level = Convert.ToString(reader["Level"]);
                    this.m_Source = Convert.ToString(reader["Source"]);
                    this.m_TotalValue = Convert.ToDecimal(reader["TotalValue"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_DecideDate = Convert.ToDateTime(reader["DecideDate"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_REWARD_GetList");
        }

        public DataTable GetListByDate(DateTime BeginDate, DateTime EndDate)
        {
            string[] myParams = new string[] { "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_REWARD_GetListByDate", myParams, myValues);
        }

        public DataTable GetListByID(string RewardCode)
        {
            string[] myParams = new string[] { "@RewardCode" };
            object[] myValues = new object[] { RewardCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_REWARD_GetListByID", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@RewardCode", "@Foundation", "@Reason", "@Object", "@Form", "@Level", "@Source", "@TotalValue", "@Status", "@Date", "@DecideNumber", "@DecideDate", "@Person" };
            object[] myValues = new object[] { this.m_RewardCode, this.m_Foundation, this.m_Reason, this.m_Object, this.m_Form, this.m_Level, this.m_Source, this.m_TotalValue, this.m_Status, this.m_Date, this.m_DecideNumber, this.m_DecideDate, this.m_Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_REWARD_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@RewardCode", "@Foundation", "@Reason", "@Object", "@Form", "@Level", "@Source", "@TotalValue", "@Status", "@Date", "@DecideNumber", "@DecideDate", "@Person" };
            object[] myValues = new object[] { this.m_RewardCode, this.m_Foundation, this.m_Reason, this.m_Object, this.m_Form, this.m_Level, this.m_Source, this.m_TotalValue, this.m_Status, this.m_Date, this.m_DecideNumber, this.m_DecideDate, this.m_Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_REWARD_Insert", myParams, myValues);
        }

        public string Insert(string RewardCode, string Foundation, string Reason, string Object, string Form, string Level, string Source, decimal TotalValue, int Status, DateTime Date, string DecideNumber, DateTime DecideDate, string Person)
        {
            string[] myParams = new string[] { "@RewardCode", "@Foundation", "@Reason", "@Object", "@Form", "@Level", "@Source", "@TotalValue", "@Status", "@Date", "@DecideNumber", "@DecideDate", "@Person" };
            object[] myValues = new object[] { RewardCode, Foundation, Reason, Object, Form, Level, Source, TotalValue, Status, Date, DecideNumber, DecideDate, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_REWARD_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, string RewardCode, string Foundation, string Reason, string Object, string Form, string Level, string Source, decimal TotalValue, int Status, DateTime Date, string DecideNumber, DateTime DecideDate, string Person)
        {
            string[] myParams = new string[] { "@RewardCode", "@Foundation", "@Reason", "@Object", "@Form", "@Level", "@Source", "@TotalValue", "@Status", "@Date", "@DecideNumber", "@DecideDate", "@Person" };
            object[] myValues = new object[] { RewardCode, Foundation, Reason, Object, Form, Level, Source, TotalValue, Status, Date, DecideNumber, DecideDate, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_REWARD_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, string RewardCode, string Foundation, string Reason, string Object, string Form, string Level, string Source, decimal TotalValue, int Status, DateTime Date, string DecideNumber, DateTime DecideDate, string Person)
        {
            string[] myParams = new string[] { "@RewardCode", "@Foundation", "@Reason", "@Object", "@Form", "@Level", "@Source", "@TotalValue", "@Status", "@Date", "@DecideNumber", "@DecideDate", "@Person" };
            object[] myValues = new object[] { RewardCode, Foundation, Reason, Object, Form, Level, Source, TotalValue, Status, Date, DecideNumber, DecideDate, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_REWARD_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_REWARD", "RewardCode", "KT");
        }

        public string Update()
        {
            string[] myParams = new string[] { "@RewardCode", "@Foundation", "@Reason", "@Object", "@Form", "@Level", "@Source", "@TotalValue", "@Status", "@Date", "@DecideNumber", "@DecideDate", "@Person" };
            object[] myValues = new object[] { this.m_RewardCode, this.m_Foundation, this.m_Reason, this.m_Object, this.m_Form, this.m_Level, this.m_Source, this.m_TotalValue, this.m_Status, this.m_Date, this.m_DecideNumber, this.m_DecideDate, this.m_Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_REWARD_Update", myParams, myValues);
        }

        public string Update(string RewardCode, string Foundation, string Reason, string Object, string Form, string Level, string Source, decimal TotalValue, int Status, DateTime Date, string DecideNumber, DateTime DecideDate, string Person)
        {
            string[] myParams = new string[] { "@RewardCode", "@Foundation", "@Reason", "@Object", "@Form", "@Level", "@Source", "@TotalValue", "@Status", "@Date", "@DecideNumber", "@DecideDate", "@Person" };
            object[] myValues = new object[] { RewardCode, Foundation, Reason, Object, Form, Level, Source, TotalValue, Status, Date, DecideNumber, DecideDate, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_REWARD_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, string RewardCode, string Foundation, string Reason, string Object, string Form, string Level, string Source, decimal TotalValue, int Status, DateTime Date, string DecideNumber, DateTime DecideDate, string Person)
        {
            string[] myParams = new string[] { "@RewardCode", "@Foundation", "@Reason", "@Object", "@Form", "@Level", "@Source", "@TotalValue", "@Status", "@Date", "@DecideNumber", "@DecideDate", "@Person" };
            object[] myValues = new object[] { RewardCode, Foundation, Reason, Object, Form, Level, Source, TotalValue, Status, Date, DecideNumber, DecideDate, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_REWARD_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, string RewardCode, string Foundation, string Reason, string Object, string Form, string Level, string Source, decimal TotalValue, int Status, DateTime Date, string DecideNumber, DateTime DecideDate, string Person)
        {
            string[] myParams = new string[] { "@RewardCode", "@Foundation", "@Reason", "@Object", "@Form", "@Level", "@Source", "@TotalValue", "@Status", "@Date", "@DecideNumber", "@DecideDate", "@Person" };
            object[] myValues = new object[] { RewardCode, Foundation, Reason, Object, Form, Level, Source, TotalValue, Status, Date, DecideNumber, DecideDate, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_REWARD_Update", myParams, myValues);
        }

        [Category("Column"), DisplayName("Date")]
        public DateTime Date
        {
            get
            {
                return this.m_Date;
            }
            set
            {
                this.m_Date = value;
            }
        }

        [Category("Column"), DisplayName("DecideDate")]
        public DateTime DecideDate
        {
            get
            {
                return this.m_DecideDate;
            }
            set
            {
                this.m_DecideDate = value;
            }
        }

        [DisplayName("DecideNumber"), Category("Column")]
        public string DecideNumber
        {
            get
            {
                return this.m_DecideNumber;
            }
            set
            {
                this.m_DecideNumber = value;
            }
        }

        [Category("Column"), DisplayName("Form")]
        public string Form
        {
            get
            {
                return this.m_Form;
            }
            set
            {
                this.m_Form = value;
            }
        }

        [DisplayName("Foundation"), Category("Column")]
        public string Foundation
        {
            get
            {
                return this.m_Foundation;
            }
            set
            {
                this.m_Foundation = value;
            }
        }

        [DisplayName("Level"), Category("Column")]
        public string Level
        {
            get
            {
                return this.m_Level;
            }
            set
            {
                this.m_Level = value;
            }
        }

        [DisplayName("Object"), Category("Column")]
        public string Object
        {
            get
            {
                return this.m_Object;
            }
            set
            {
                this.m_Object = value;
            }
        }

        [DisplayName("Person"), Category("Column")]
        public string Person
        {
            get
            {
                return this.m_Person;
            }
            set
            {
                this.m_Person = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_REWARD";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [Category("Column"), DisplayName("Reason")]
        public string Reason
        {
            get
            {
                return this.m_Reason;
            }
            set
            {
                this.m_Reason = value;
            }
        }

        [Category("Primary Key"), DisplayName("RewardCode")]
        public string RewardCode
        {
            get
            {
                return this.m_RewardCode;
            }
            set
            {
                this.m_RewardCode = value;
            }
        }

        [Category("Column"), DisplayName("Source")]
        public string Source
        {
            get
            {
                return this.m_Source;
            }
            set
            {
                this.m_Source = value;
            }
        }

        [DisplayName("Status"), Category("Column")]
        public int Status
        {
            get
            {
                return this.m_Status;
            }
            set
            {
                this.m_Status = value;
            }
        }

        [DisplayName("TotalValue"), Category("Column")]
        public decimal TotalValue
        {
            get
            {
                return this.m_TotalValue;
            }
            set
            {
                this.m_TotalValue = value;
            }
        }
    }
}

